<!--# include virtual="/admin/common/html/header.html"-->
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 信息价管理 <span class="c-gray en">&gt;</span> 信息价管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		状态：<span class="select-box inline">
			<select name="state"  id="state" class="select" >
				<option value="" selected="selected">全部分类</option>
				<option value="0" >待审核</option>
				<option value="1">已审核</option>
				<option value="2">未通过</option>
			</select>
		</span>
		工程分类：<span class="select-box inline">
			<select name=""  id="catalogId" class="select">
				<option value="" selected="selected">全部分类</option>
			</select>
		</span> 
		工程名称：<input  id="costName" name="costName"  class="input-text" style="width:200px;"> 
		<button name="searchButton" id="searchButton" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>搜索</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
	    <a class="btn btn-primary radius" onclick="guidance_open('新增工程','/admin/modules/datashare/base/_form.html')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>新增工程</a>
		<!--<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>--> 
		<!--<a class="btn btn-primary radius"  onclick="deleteMany()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>批量删除</a>-->
		<!--<a class="btn btn-primary radius"  id="input"  href="javascript:;">
			<i class="Hui-iconfont"  style="font-size: 18px;">&#xe645;</i>导入
		</a>
		<a class="btn btn-link" href="/api/upload/dowloadTemplate?type=5" target="_blank">下载导入模板</a>-->
		</span> 
		<span class="r"></span> 
	</div>
	<div class="mt-20">
		<table id="firm-post-list" class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="13"><input type="checkbox" name="" value=""></th>	
					<th width="50">工程名字</th>
					<th width="50">工程分类</th>
					<th width="50">工程地点</th>
					<th width="150">总建筑面积</th>
					<th width="50">建筑总高度</th>
					<th width="50">建筑总层数</th>
					<th width="50">提交人</th>
					<th width="100">提交时间</th>
					<th width="50">审核人</th>
					<th width="100">审核时间</th>
					<th width="25" >状态</th>
					<th width="50">操作</th>
				</tr>
			</thead>
			<tbody>				
			</tbody>
		</table>
	</div>
</div>
<!--# include virtual="/admin/common/html/_footer.html"-->
<!--# include virtual="/admin/modules/datashare/base/_list_curd.html"-->
<script type="text/javascript">
	var catalogObj={};
$(function() {
	$.ajax({
		type:"post",
		url:"/guidance_service/front/data/catalog/searchByCache.do",
		async:false,
		success:function(result){
			var catalog=result.data;
			$.each(catalog,function(i,item){
				if(item.parentId=='1'){
					$("#catalogId").append("<option value='"+item.catalogId+"'>"+item.catalogName+"</option>");
				}
				catalogObj[item.catalogId]=item;
			});
		}
	});
	
	var user = {
		getQueryCondition: function(data) {
			var param = {};
			param.costName = $.trim($("#costName").val());
			param.catalogId = $.trim($("#catalogId").val());
			param.pageNumber = Number(data.start/data.length)+1  || 1;
			param.pageSize = data.length   || 15;
			param.state=$("#state").val();
			return param;
		}
	};
    var dataTable = $("#firm-post-list").zosoftDataTable({
    	searchButton:"#searchButton",
    	"aaSorting":[[ 5, "asc" ]] ,
    	"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,1,2,3,4,6,7 ] }]  ,
		ajax: function(data, callback) { //ajax配置为function,手动调用异步查询
//			$.post("/guidance_service/front/guidance/guidanceList.do", user.getQueryCondition(data),function(result) {
				$.post("/guidance_service/front/data/dataList.do", user.getQueryCondition(data),function(result) {
						//封装返回数据，这里仅演示了修改属性名
						var returnData = {};
						returnData.recordsTotal = result.data.totalRow;
						returnData.recordsFiltered = result.data.totalRow; //后台不实现过滤功能，每次查询均视作全部结果
						returnData.data = result.data.list;
						callback(returnData);
				});
//			});
		},
		//使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属性
		//data 这里是固定不变的，id，name，age，sex等为你数据里对应的属性
		columns: [
			{
				data: "costId",
				render: function(data) {
					return '<input type="checkbox" name="costId" value="' + data + '" class="costId">';
				}
			},
			{
				data: "costName",
				render: function(data, type, row) {
					return '<a style="text-decoration:none" class="ml-5" onClick="data_open(\''+data+'\',\'/admin/modules/datashare/info/infoList.html?costId=' 
					+ row.costId + '\')" href="javascript:;" title="查看详情">'+data+'</a>';
				}
			},
			{
				data: "catalogId", //
				render: function(data,type, row) {
					if(catalogObj[data]){
						return catalogObj[data].catalogName
					}else{
						return "";
					}
				}
			},
			{
				data: "address",
				render: function(data) {
					return data || "";
				}
			},
			{
				data: "totalArea",
				render: function(data, type, row) {
					return data || "";
				}
			},
			{
				data: "projectHeight", //
				render: function(data) {
					return data || "";
				}
			},
			{
				data: "totalFloor", //
				render: function(data, type, row) {
					return data || "";
				}
			},
			{
				data: "createUserId",
				render: function(data) {
					//sessionStorage.setItem("fieldId",data)
					//return sessionStorage.getItem(data);
					return data || "";
				}
			},
			{
				data: "createTime",
				render: function(data) {
					//sessionStorage.setItem("fieldId",data)
					//return sessionStorage.getItem(data);
					return data || "";
				}
			},
			{
				data: "updateUserId",
				render: function(data) {
					//sessionStorage.setItem("fieldId",data)
					//return sessionStorage.getItem(data);
					return data || "";
				}
			},
			{
				data: "updateTime",
				render: function(data) {
					//sessionStorage.setItem("fieldId",data)
					//return sessionStorage.getItem(data);
					return data || "";
				}
			},
			{
				data: "state",
				render: function(data) {
					if ('0'==data) {
                    	return '<span class="label label-primary  radius">待审核</span>';
                    }else if('1'==data){
                    	return '<span class="label label-success  radius">已审核</span>';
                    }else if('2'==data){
                    	return '<span class="label label-warning  radius">未通过</span>';
                    }
				}
			},
			{
				data: "costId",
				render: function(data, type, row) {
//						return '<a style="text-decoration:none" onClick="policies_shenhe(this,' + data + ')" href="javascript:;" title="审核">审核</a>' +
					return	'<a style="text-decoration:none" class="ml-5" onClick="data_edit(\'编辑\',\'/admin/modules/datashare/base/_form.html?costId=' + data + '\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>' +
						'<a style="text-decoration:none" class="ml-5" onClick="data_del(this,' + data + ')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>';
				}
			}
		]
	});
	});
	
/*删除*/
function guidances_delete(obj,guidanceIds){
	layer.confirm('确定删除所选？', {
		btn: ['确定','取消'], 
		shade: false,
		closeBtn: 0
	},function(index){
		$.post("/guidance_service/front/guidance/logicDeleteAll.do",{ guidanceIds:guidanceIds},function(result){
			if(result.resultCode == 200){
				layer.msg("删除成功", {icon:6,time:1000},function(){
					//$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" data-id="'+$(obj).attr("data-id")+'"  onClick="article_start(this,10001)" href="javascript:;" title="开放"><i class="Hui-iconfont" style="font-size: 18px;">&#xe603;</i></a>');
					for(var i=obj.length-1;i>=0;i--){
						$("#firm-post-list tr").eq(Number(obj[i])+1).remove();
					}
					//$(obj).remove();
					layer.close(index);
				});
			}else{
				layer.msg('删除失败', {icon:5,time:1000},function(){
					layer.close(index);
				});
			}
		});
	});
}


function guidance_open(title,url,w,h){ 
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

function deleteMany(){
	var Ids ="";  
	var checkObjs=[];
	$('input[name="guidanceId"]:checked').each(function(){    
		Ids+=$(this).val()+",";   
		checkObjs.push($(this).parent().parent().index());
	});
	guidances_delete(checkObjs,Ids);
}
</script>
</body>
</html>